<!DOCTYPE html>
<?php 

$vt = 89;

$doc = $api->current()['doc'];
$docId = $doc['_id'];
if( empty($docId) ){
  header("Location: //caitong.sina.cn");
    exit;
}

$cacheKey = md5("caitong_wap_chartv20170504_{$docId}");
$html = $api->cache()->get($cacheKey);
/*if( $html !== false ){
  echo $html;
  exit;
}*/

$doc = $api->doc($docId);

//非上线状态文章
if ($doc['online'] <= 0) {
    header("Location: //caitong.sina.cn");
    exit;
}

// 获取相关必要数据
$tags = $doc['tags'];
$summary = '';
$title = $doc['title'];
$stitle = $doc['stitle'];
$docID = $doc['_id'];
$oriSource = $doc['source']['ml_signature'];
$createTime = $doc['cTime'];
$allCIDs = $doc['allCIDs'];
$pic1 = $doc['feedPic'];
$comment = $doc['comment'];
$mainPic = $doc['mainPic'];
$url = $api->current()->url;

// 生成meta title
$metaTitle = !empty($stitle) ? $stitle : $title;
// 生成keywords
$keywords = implode(",", $tags);
// 生成description
$desc = '新浪彩通为用户提供全面及时的中文彩票行业资讯，内容涵盖事件观察，行业动向探讨、国际彩票剖析、人物采访以及彩市新闻分析等深度的彩票行业资讯';
if (empty($summary)) {
    $summary = bc_helper::getContentByDocinfo($doc,true,true,true);
    $summary = BC_helper::msubstr($summary, 0, 60);
}
$description = !empty($summary) ? $summary : $desc;
// 生成媒体名称
$source = BC_WapMediaSource::getFormatSourceDate($oriSource, null);
// 生成评论ID
$commentID = "{$comment['channel']}:comos-{$docID}:0";
// 生成新闻时间
$docTime = date('Y年m月d日 H:i', strtotime($createTime));

// ================================ 处理新闻内容 ========================================
$contentBaseArr = $doc['content'];
$contentMTArr = !empty($doc['_extra']['content'][$vt]) ? $doc['_extra']['content'][$vt] : [];
$contentBase = '';
foreach ($contentBaseArr as $bs) {
    $contentBase.=$bs['content'];
}
$contentMT = '';
foreach ($contentMTArr as $mt) {
    $tmpContent = $mt['content'];
    $contentMT.=$tmpContent;
}
$contentMTTmp = trim(strip_tags($contentMT));
$content = !empty($contentMTTmp) ? $contentMT : $contentBase;

$contentHandler = new BC_Lottery_Article_Content_Handler();
$content = $contentHandler->handleContent($content, 'caitong_wap');
// 处理如果没有主图情况下的第一个div标签的间距
$content = '<div class="c_mainImg_box wrap15"></div>' . $content;
if( !empty($mainPic) ){
  $content .= '<div class="c_mainTxt"><div class="img_wrapper"><img src="' . $mainPic . '" /><span></span></div></div>';
}

// ================================ 处理新闻内容 ========================================


// ================================ 处理广告 ======================================
// 取出正文页配置
$cfgTpl = $api->userConfByPubport(130833, '广告维护', 99);
//var_dump($cfgTpl);
$adCfg = $cfgTpl['caitongWap']['value'];
$adHandler = new bc_lottery_article_wap_ad_handler();
$adsArr = $adHandler->handleAd($adCfg);
$adHtml = implode(PHP_EOL, $adsArr);
if( !empty($adsArr) ){
  $adHtml = '<div class="c_16block"></div>' . PHP_EOL . $adHtml;
}
// ================================ 处理广告 ======================================
?>
{{block var="html"}}
<html>

<head>
  <meta charset="utf-8">
  <title>{{$metaTitle|escape}}</title>
  <link rel="icon" href="http://n1.sinaimg.cn/sports/sina_lotto/caitong/wap/i/favicon64.ico" type="image/x-icon" />
  <link rel="shortcut icon" href="http://n1.sinaimg.cn/sports/sina_lotto/caitong/wap/i/favicon64.ico" type="image/x-icon" />
  <meta name="keywords" content="{{$keywords|escape}}"
  />
  <meta name="description" content="{{$description|escape}}"
  />

  <!-- Mobile Devices Support @begin -->
  <meta content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1,user-scalable=no" name="viewport" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no, email=no">
  <meta name="msapplication-tap-highlight" content="no" />
  <meta name="browsermode" content="application" />
  <meta name="x5-page-mode" content="default|app" />
  <meta name="screen-orientation" content="portrait" />
  <meta name="x5-orientation" content="portrait" />

  <meta name="referrer" content="always">
  <meta name="sudameta" content="allCIDs:<?=implode(",", $allCIDs);?>">
  <meta property="og:type" content="news"/>
  <meta property="og:title" content="{{$metaTitle|escape}}" />
  <meta property="og:description" content="{{$metaTitle|escape}}" />
  <meta property="og:url" content="{{$url}}" />
    
  <meta property="article:author" content="{{$source}}"/> 
  <meta property="article:published_time" content="{{$createTime}}" />
  <meta name="publishid" content="{{$docID}}" />
        
  <!-- 搜索引擎 辅助抓站 -->
  <meta name="robots" content="index, follow" />
  <meta name="googlebot" content="index, follow" />
  <meta name="baidu-site-verification" content="rTnMzcp5WP" />
  <meta name="shenma-site-verification" content="0c910b838092fac1fb183f3de2eeb30a" /> 
  <!-- Mobile Devices Support @end -->
  <script type="text/javascript">
    //公共全局配置文件
    var globalConfig = {
      startTime: new Date().getTime(), //页面开始渲染时间 ， 目前应用于：日志统计、性能统计。
      isLogin: false
    }
    window._preventTanChuang_ = true;
    window.shareInfo = { //分享相关
      desc: "{{$metaTitle|escape}}", // 描述
      img: "{{$pic1|escape}}", // 图片
      img_title: null, // 图片标题
      from: "{{$url|escape}}", // 来源
    }
    // 评论相关
    window.conf_comment = {
      docID: "{{$docID|escape}}",
      commentId: "{{$commentID|escape}}",
    }

  </script>
  <script src="http://mjs.sinaimg.cn/wap/public/suda/201605101615/suda_log.min.js"></script>

<link href="//n.sinaimg.cn/sports/sina_lotto/ct_textPage/wap/css/app.css?v=a19c" rel="stylesheet"></head>

<body>
  <div id="app"></div>
  <!--正文开始 cms start-->
  <div class="staticApp content">
    <!--标题模块-->
    <div class="c_tit_box wrap15">
      <h1 class="c_tit">{{$metaTitle|escape}}</h1>
      <div class="c_titLabel clearfix">
        <span class="c_author">{{$source|escape}}</span>
        <span class="c_time">{{$docTime}}</span>
      </div>
    </div>
    <!--主图模块-->
    {{if !empty($pics)}}
    <div class="c_mainImg_box wrap15">
      {{foreach from=$pics item="mainPic" key="k"}}
      <div class="c_mainImg">
        <a href="{{$mainPic.imgurl|escape}}" data-caption="{{$mainPic.note|escape}}">
        <img src="{{$mainPic.imgurl|escape}}" alt="{{$mainPic.note|escape}}">
        </a>
        <span>{{$mainPic.note|escape}}</span>
      </div>
      {{endforeach}}
    </div>
    {{endif}}
    <!--内容模块-->
    <div class="c_mainTxt_box wrap15">
      <div class="c_mainTxtContainer">
        {{$content}}
      </div>
      <!--<div class="c_txtInfo">
        <span>南方日报记者</span>
        <span>朱小龙</span>
      </div>-->
      <div class="c_txtBtn" data-status="hideP">点击查看全文</div>
    </div>

    <!--分享模块-->
    <div class="c_share_box wrap15 clearfix">
      <span class="c_shareLabel">分享到：</span>
      <span class="c_shareFC c_shareBlock" data-shareId="weixinFriend">
        <img src="" alt="">
      </span>
      <span class="c_shareWX c_shareBlock" data-shareId="weixin">
        <img src="" alt="">        
      </span>
      <span class="c_shareWeibo c_shareBlock" data-shareId="sinaWeibo">
        <img src="" alt="">        
      </span>
      <span class="c_shareQQ c_shareBlock" data-shareId="QQ">
        <img src="" alt="">        
      </span>
      <div class="bshare-custom icon-medium" id="bshareBox">
        <div class="bsPromo bsPromo2"></div>
        <a class=" bshare-sinaminiblog" title="分享到新浪微博">
        </a>
        <span class="c_bshareWeibo">
          <img src="" alt="">
          </span>
      </div>
    </div>
    <!--正文结束 cms end->
 <!--彩通推广图-->
    <div class="ct_pushImg wrap15 c_pnCard">
      <img src="//www.sinaimg.cn/ty/temp/up/2017-05-16/U8314P6T64D100415F1091DT20170516093547.png" alt="" data-height="0.347">
    </div>
<!--评论模块-->
    <div id="comApp"></div>
 

    <!--广告卡片模块-->
    <div class="c_pushNewsCards_box">
      {{$adHtml}}
    </div>

    <!--精彩推荐模块-->
    <div  id="feedApp"></div>
  </div>

  <script type="text/javascript" src="http://i.sso.sina.com.cn/js/ssologin.js"></script>
  <script type="text/javascript" src="http://i.sso.sina.com.cn/js/outlogin_layer_mobile.js" charset="utf-8"></script>

  <!-- built files will be auto injected -->
<script type="text/javascript" src="//n.sinaimg.cn/sports/sina_lotto/ct_textPage/wap/js/manifest.js?v=a19"></script>
<script type="text/javascript" src="//n.sinaimg.cn/sports/sina_lotto/ct_textPage/wap/js/vendor.js?v=a19">
</script><script type="text/javascript" src="//n.sinaimg.cn/sports/sina_lotto/ct_textPage/wap/js/app.js?v=a19"></script>
</body>

</html>
{{endblock}}
<?php 

echo $html;
$api->cache()->set($cacheKey, $html, 300);
?>